package com.freemalll.system.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.freemalll.system.domain.SysAccountLeader;
import com.freemalll.system.mapper.SysAccountLeaderMapper;
import com.freemalll.system.service.ISysAccountLeaderService;

/**
 * 账户领导关系 服务层实现
 * 
 * @author freemalll
 */
@Service
public class SysAccountLeaderServiceImpl implements ISysAccountLeaderService
{
    @Autowired
    private SysAccountLeaderMapper accountLeaderMapper;

    /**
     * 查询账户领导关系信息
     * 
     * @param id 账户领导关系ID
     * @return 账户领导关系信息
     */
    @Override
    public SysAccountLeader selectAccountLeaderById(String id)
    {
        return accountLeaderMapper.selectAccountLeaderById(id);
    }

    /**
     * 根据账户ID查询领导关系
     * 
     * @param accountId 账户ID
     * @return 账户领导关系集合
     */
    @Override
    public List<SysAccountLeader> selectAccountLeaderByAccountId(String accountId)
    {
        return accountLeaderMapper.selectAccountLeaderByAccountId(accountId);
    }

    /**
     * 根据领导账户ID查询下属关系
     * 
     * @param leaderAccountId 领导账户ID
     * @return 账户领导关系集合
     */
    @Override
    public List<SysAccountLeader> selectAccountLeaderByLeaderId(String leaderAccountId)
    {
        return accountLeaderMapper.selectAccountLeaderByLeaderId(leaderAccountId);
    }

    /**
     * 查询账户领导关系列表
     * 
     * @param accountLeader 账户领导关系信息
     * @return 账户领导关系集合
     */
    @Override
    public List<SysAccountLeader> selectAccountLeaderList(SysAccountLeader accountLeader)
    {
        return accountLeaderMapper.selectAccountLeaderList(accountLeader);
    }

    /**
     * 新增账户领导关系
     * 
     * @param accountLeader 账户领导关系信息
     * @return 结果
     */
    @Override
    public int insertAccountLeader(SysAccountLeader accountLeader)
    {
        return accountLeaderMapper.insert(accountLeader);
    }

    /**
     * 修改账户领导关系
     * 
     * @param accountLeader 账户领导关系信息
     * @return 结果
     */
    @Override
    public int updateAccountLeader(SysAccountLeader accountLeader)
    {
        return accountLeaderMapper.updateById(accountLeader);
    }

    /**
     * 批量删除账户领导关系
     * 
     * @param ids 需要删除的账户领导关系ID
     */
    @Override
    public void deleteAccountLeaderByIds(String[] ids)
    {
        for (String id : ids)
        {
            accountLeaderMapper.deleteAccountLeaderById(id);
        }
    }

    /**
     * 删除账户领导关系信息
     * 
     * @param id 账户领导关系ID
     * @return 结果
     */
    @Override
    public int deleteAccountLeaderById(String id)
    {
        return accountLeaderMapper.deleteAccountLeaderById(id);
    }

    /**
     * 根据账户ID删除所有相关关系
     * 
     * @param accountId 账户ID
     * @return 结果
     */
    @Override
    public int deleteAccountLeaderByAccountId(String accountId)
    {
        return accountLeaderMapper.deleteAccountLeaderByAccountId(accountId);
    }

    /**
     * 根据领导账户ID删除所有相关关系
     * 
     * @param leaderAccountId 领导账户ID
     * @return 结果
     */
    @Override
    public int deleteAccountLeaderByLeaderId(String leaderAccountId)
    {
        return accountLeaderMapper.deleteAccountLeaderByLeaderId(leaderAccountId);
    }

    /**
     * 批量添加账户领导关系
     * 
     * @param accountLeaderList 账户领导关系列表
     * @return 结果
     */
    @Override
    public int batchInsertAccountLeader(List<SysAccountLeader> accountLeaderList)
    {
        int count = 0;
        for (SysAccountLeader accountLeader : accountLeaderList)
        {
            count += accountLeaderMapper.insert(accountLeader);
        }
        return count;
    }
}